package nimble.pay.trade.server.controller.trade;

import nimble.pay.trade.server.framework.TradeProcessor;
import nimble.pay.trade.specification.TradeObject;
import nimble.pay.trade.server.system.processor.ServerTradeProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author max woods
 * @date 2018/8/6
 * 交易请求处理控制器
 */

@RestController
@RequestMapping("/api")
public class TradeController {

  private static final Logger logger = LoggerFactory.getLogger(TradeController.class);

  private TradeProcessor tradeProcessor;

  @Autowired
  public TradeController(ServerTradeProcessor serverTradeProcessor)
  {
    this.tradeProcessor= serverTradeProcessor;
  }

  @RequestMapping("/trade")
  public TradeObject trade(@RequestBody TradeObject request) {
    logger.info("=========交易请求========");
    TradeObject response=new TradeObject();
    tradeProcessor.processTrade(request,response);
    return response;
  }
}
